<template>
  <div class="dashboard-container">
    <div style="padding-left:2%;padding-bottom:15px;padding-top:15px;"> num++执行的什么时候等于自己什么时候自加了一 </div>
     <div style="padding-left:2%;padding-bottom:15px;padding-top:15px;"> Dashboard  Documentation  Guide  icons Charts  Nested Routes  Table  tab  Error Pages  ErrorLog 
          这些文件夹都可以看看 有的是面试题 有的是封装 有的是一些常见的问题的处理   
     </div>
     <div @click="loadFm">
         下载
     </div>
      <div @click="loadCloseFm">
         下载
     </div>
    <component :is="currentRole" />
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import adminDashboard from './admin'
import editorDashboard from './editor'

export default {
  name: 'Dashboard',
  components: { adminDashboard, editorDashboard },
  data() {
    return {
      currentRole: 'adminDashboard'
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  created() {
      let cum=0
      console.log(cum++)//0

    // let cum=0
    // cum++
    // console.log(cum)//1

    if (!this.roles.includes('admin')) {
      this.currentRole = 'editorDashboard'
    }

  },
  methods:{
    loadCloseFm(){
      window.open('about:blank','_self').close()
    },
      loadFm(){
          //window.location.href='http://150.158.108.92/worldPdf/教育部学历证书电子注册备案表_林李明.pdf'
           const blob = new Blob([res], {
            type: "application/pdf;chartset=UTF-8",
          });
          const a = document.createElement("a");
          const URL = window.URL || window.webkitURL;
          const herf = URL.createObjectURL(blob);
          a.href = herf;
          // 这里后台不给文件名字需要自己写
          a.download = '履约码文件.pdf';
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
          window.URL.revokeObjectURL(herf);


      }
  }
}
</script>
